import { withRouter } from 'next/router'
import axios from 'axios'

function Index(props) {
  console.log(props)
  return (
    <div>
      blog/index
      <div className="systemName">{props.data[0].name}</div>
      <style jsx>
        {`
          .systemName {
            color: blue;
          }
        `}
      </style>
    </div>
  )
}

Index.getInitialProps = async () => {
  const list = await new Promise((resolve) => {
    axios(
      'https://mstest.viomi.com.cn/auth-web/services/resource/userSystemMenu.json?token=XQxK96dSgNp76XDf&systemId=1',
    ).then((res) => {
      console.log('远程数据结果：', res)
      resolve({ data: res.data.mobBaseRes.datas })
    })
  })
  return list
}

export default withRouter(Index)
